import request from "@/utils/request";

// 平台属性值类型
export interface attrValueItemType {
  id?: number;
  valueName: string;
  attrId?: number;
  isEdit?: boolean;
}

// 平台属性值列表类型
export type attrValueListType = attrValueItemType[];

// 平台属性类型
export interface attrInfoItemType {
  id?: number;
  attrName: string;
  categoryId?: number;
  categoryLevel: number;
  attrValueList: attrValueListType;
}
// 平台属性列表类型
export type attrInfoListType = attrInfoItemType[];

// 请求平台属性列表
export const reqGetAttrInfoList = (
  category1Id: number,
  category2Id: number,
  category3Id: number
) => {
  return request.get<null, attrInfoListType>(
    `/admin/product/attrInfoList/${category1Id}/${category2Id}/${category3Id}`
  );
};

// 请求删除某个平台属性数据
export const reqDeleteAttr = (attrId: number) => {
  return request.delete<null, null>(`/admin/product/deleteAttr/${attrId}`);
};

// 请求新增或者修改某个平台属性数据
export const reqSaveAttrInfo = (attrInfo: attrInfoItemType) => {
  return request.post<null, null>(`/admin/product/saveAttrInfo`, attrInfo);
};
